// 引入polyfill
// import '@babel/polyfill'
// 断言
import "./core/utils/assert";
// 错误监听
import "./core/error_handle";

import { IS_DEBUG } from "./config/global";
import { createLogger, logSection } from "./core/utils/logging";
import { Application } from "./application";

const logger = createLogger("main");

if (window.coreThreadLoadedCb) {
	logger.log("JS解析完毕，等待页面加载。");
	window.coreThreadLoadedCb();
}

console.log(
	`%c修仙世界从零开始 %c\n© 2021 Lionet Commit %c${G_BUILD_COMMIT_HASH}%c on %c${new Date(
		G_BUILD_TIME
	).toLocaleString()}\n`,
	"font-size: 35px; font-family: Arial; font-weight: bold; padding: 10px 0;",
	"color: #aaa",
	"color: #vvv",
	"color: #aaa",
	"color: #vvv"
);

console.log("当前环境: %c" + G_APP_ENVIRONMENT, "color: #ccc");

if (G_IS_DEV && IS_DEBUG) {
	console.log("\n%c🛑 DEBUG 🛑\n", "color: #f77");
}

/* typehints:start */
assert(false, "检测typehints是否工作");
/* typehints:end */

/* dev:start */
console.log("%c检测dev是否工作", "color: #f77");
/* dev:end */

logSection("主线程", "#f9a825");

let app = null;

function bootApp() {
	logger.log("Page loaded");
	app = new Application();
	app.boot();
}

window.addEventListener("load", bootApp);
